package com.haiermzj;

import android.app.Application;
import android.widget.Toast;

import com.haier.user.center.UserCenterConfig;
import com.haier.user.center.model.AccessToken;
import com.haier.user.center.model.BaseError;
import com.haier.user.center.openapi.UserCenterApi;
import com.haier.user.center.openapi.handler.ClientTokenCallHandler;

/**
 * Created by wanghaixin on 17/9/29.
 */
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
          /*海尔用户中心*/
        UserCenterConfig.getInstance().setDomain("http://taccount.haier.com");//http://taccount-api.haier.net
        UserCenterConfig.getInstance().setOauthDomain(" http://taccount.haier.com");//http://account.haier.com
        UserCenterApi.initUserCenter(this, "rsqmczl", "xpm87hB6jqgz3t");
//        UserCenterApi.initUserCenter(this, "rsqmczl", "xpm87hB6jqgz3t");
        UserCenterApi.clientAccessToken(new ClientTokenCallHandler() {
            @Override
            public void onSuccess(AccessToken token) {
//                        Intent intent = new Intent();
//                        intent.putExtra("test", "authorize intent");
//                        UserCenterApi.authorize(LoginActivity.this, intent);
                Toast.makeText(getBaseContext(), "onSuccess" + token.getAccess_token(), Toast.LENGTH_SHORT).show();

            }

            @Override
            public void onFailed(BaseError error) {
                Toast.makeText(getBaseContext(), "onFailed" + error.getError_description(), Toast.LENGTH_SHORT).show();
            }
        });
    }
}
